﻿
function IsDigit() {
	return ((event.keyCode==13)||((event.keyCode >= 48) && (event.keyCode <= 57)));
}

function IsDecimal(id){
	var cost = document.getElementById(id);
	var pattern0 = /^\d{0,31}$/;
	var pattern2 = /^[0-9]{1,28}\.[0-9]{0,2}$/;
	var k=event.keyCode;
	if(k!=46&&k!=13&& (k>57 || k<48)){
		alert("只能输入数字或小数点,如1.00");
		cost.focus();
		return false;
	}
	if(cost.value!=null&&cost.value.length>0){
		if((!pattern0.test(cost.value)&&!pattern2.test(cost.value))||cost.value<0){
			alert("整数位不得小于1位大于28位,小数位不得超过2位，有且只有一个小数点");
			cost.focus();
			return false;
		}		
	}
	return true;
}

function IsPrice(price){
	var pattern = /^[0-9]{1,28}\.[0-9]{1,2}$/;
	return pattern.test(price);
}

function IsDate(y, m, d) {
	day_t = new Date(y, m - 1);
	if (y != day_t.getFullYear() || m != (day_t.getMonth() + 1)) {
		return false;
	}
	return true;
}
function IsNumber(number) {
	var pattern = /^\d+$/;
	return (pattern.test(number));
}
function IsFloat(number) {
	var pattern = /^\d+(.{0,1})\d+$/;
	return (pattern.test(number));
}
function IsEmail(email) {
	var pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return (pattern.test(email));
}
function IsPhone(phone) {
	var pattern = /^\d+(-{0,1})\d+$/;
	return (pattern.test(phone));
}
function IsName(name) {
	var pattern = /^[\u0391-\uFFE5a-zA-Z]+$/;
	return (pattern.test(name));
}
function IsLoginName(loginname) {
	var pattern = /^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){0,9}$/;
	return (pattern.test(loginname));
}
function checkStrSize(str, min, max) {
	if (str == null || str.length < 1) {
		return false;
	}
	if (str.length < min) {
		return false;
	}
	if (str.length > max) {
		return false;
	}
	return true;
}

function IfEfileType(file)
{
    
  var filetype;
  var filename;
  filename = file.value;      
  filetype = filename.substr(filename.lastIndexOf("."),filename.length-1);
  if(filetype.toUpperCase()!=".GIF"&&filetype.toUpperCase()!=".BMP"&&filetype.toUpperCase()!=".JPEG"&&filetype.toUpperCase()!=".JPG"){
    
  	return false;
  }
  return true;
}

function hasChinese(str){
	var pattern = /^[\u4e00-\u9fa5]*$/;
	return pattern.test(str);
}


function gotoUrl(url,projectid){
	if(projectid==null || projectid.length<1){
		alert("先填写项目基本信息");
		return false;
	}
	else{
		window.location=url;
	}
	
}